package com.example.administrator.u17.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.u17.R;
import com.example.administrator.u17.model.TwoPicMoreComics;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2016/11/15.
 */

public class TwoPicMoreAdapter extends BaseAdapter{
    private Context context;
    private List<TwoPicMoreComics> list;

    public TwoPicMoreAdapter(Context context, List<TwoPicMoreComics> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TwoPicMoreViewHolder holder;
        if (convertView==null){
            convertView=View.inflate(context,R.layout.item_twopic_more,null);
            holder=new TwoPicMoreViewHolder(convertView);
            convertView.setTag(holder);
        }else{
            holder=(TwoPicMoreViewHolder)convertView.getTag();
        }
        TwoPicMoreComics comics = list.get(position);
        holder.tvTitle.setText(comics.title);
        holder.tvTime.setText(comics.subTitle);
        Picasso.with(context).load(comics.cover).into(holder.iv);
        return convertView;
    }

    class TwoPicMoreViewHolder{
        TextView tvTitle,tvTime;
        ImageView iv;
        public TwoPicMoreViewHolder(View view){
            tvTitle=(TextView)view.findViewById(R.id.tv_item_two_pic_more_title);
            tvTime=(TextView)view.findViewById(R.id.tv_item_two_pic_more_time);
            iv=(ImageView)view.findViewById(R.id.iv_item_two_pic_more);
        }
    }
}
